package com.dingshi.security.adapter;

import java.util.ArrayList;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.dingshi.security.R;
import com.dingshi.security.entity.Track;

public class OnDutyAdapter extends BaseAdapter{

	private Context context;
	private LayoutInflater inflater;
	private String name;

	public OnDutyAdapter(Context context,ArrayList<Track> list) {
		this.context = context;
		inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
	}
	
	public OnDutyAdapter(Context context, String guardName) {
		this.context = context;
		this.name = guardName;
		inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
	}

	@Override
	public int getCount() {
		return 1;
	}

	@Override
	public Object getItem(int position) {
		return null;
	}

	@Override
	public long getItemId(int position) {
		return 0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		ViewHolder holder = null;
		if (convertView == null) {
			convertView = inflater.inflate(R.layout.spinner_item, null);
			holder = new ViewHolder();
			holder.spinner_item = (TextView) convertView.findViewById(android.R.id.text1);
			convertView.setTag(holder);
		} else {
			holder = (ViewHolder) convertView.getTag();
		}

		updateData(holder, name);
		return convertView;
	}

	private void updateData(ViewHolder holder, String name) {
		holder.spinner_item.setText(name!=null?name:"未知");
	}
	static class ViewHolder {
		public TextView spinner_item;
	}
}
